package com.teaphy.coroutinecrawler.flow.operators.transform

import kotlinx.coroutines.*
import kotlinx.coroutines.flow.*

fun main() = runBlocking {
    val chars = listOf("A", "B", "C", "D")

    flow {
        emit(1)
        emit(2)
        emit(3)
    }.onEach { println("onEach: $it") }
        .mapNotNull {
            println("map --> data: $it")
            delay(100 )

            if (it % 2 == 0) {
                null
            } else {
                "$it - ${chars[it]}"
            }
        }.collect {
            println(it)
        }
    println("Done")
}